<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:h="http://xmlns.jcp.org/jsf/html"
      xmlns:p="http://primefaces.org/ui"
      xmlns:f="http://xmlns.jcp.org/jsf/core"
      xmlns:ui="http://xmlns.jcp.org/jsf/facelets"
      xmlns:c="http://xmlns.jcp.org/jsp/jstl/core">
    <h:head>
        <title>Roles en Oracle</title>
        <link rel="shortcut icon" href="../Data/images/Saved-Data-Utility.ico" type="image/x-icon"/>
        <link rel="stylesheet" href="../Data/CSS/content.css" type="text/css"/>
    </h:head>
    <h:body>
        <h:form id="formlistRoles">
            <p:growl id="msgRoles" showDetail="true" life="10000" autoUpdate="true"/>

            <h:panelGrid style="margin: 0 auto">
                <p:outputLabel value="ADMINISTRACI&Oacute;N DE ROLES" style="color: #2480BC; font-weight: bold; font-size: 1.3em;"/>
            </h:panelGrid>
            
            <p:tabView dynamic="true" activeIndex="#{rolBean.ntab}" id="tabViewRol" >

                <p:tab title="Roles" disabled="false" > 
                    <center><p:outputLabel value="Listado de Roles" style="color: #2480BC; font-size: 1.1em"/></center>
                    
                    <center><p:commandButton value="Editar" 
                                action="#{rolBean.edit}" 
                                update="tabViewRol"/>
                    <label>&emsp;&emsp;</label>
                    <p:commandButton icon="ui-icon-trash" value="Eliminar"
                                     ajax="false" action="#{rolBean.delete()}">
                    </p:commandButton>
                    </center>
                        <p:dataTable id="dataTableRoles" var="rol" 
                                     value="#{rolBean.tableModel}"
                                    paginator="true" rows="10"
                                    paginatorTemplate="{CurrentPageReport}  {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} {RowsPerPageDropdown}" 
                                    rowsPerPageTemplate="5,10,15"
                                    selection="#{rolBean.selectedRol}"
                                    selectionMode="single"
                                    rowKey="#{rol.name}"
                                    editable="true"
                                    >
            
                            <p:column headerText="Usuario">  
                                <h:outputText value="#{rol.name}" />  
                            </p:column>  

                            <p:column headerText="Autenticaci&oacute;n" style="text-align: center">  
                                <h:outputText value="#{rol.autentication}" />
                            </p:column>  

                            
                        </p:dataTable> 
                        
                        <p:confirmDialog id="confirmDialog" message="¿Desea Eliminar el rol?" header="Eliminar Rol" 
                                         severity="alert" 
                                         showEffect="fade"
                                         hideEffect="explore"
                                         widgetVar="confirmDelete">  
                            <p:commandButton value="Si" ajax="false"
                                             onclick="#{rolBean.delete( )};" />  
                            <p:commandButton value="No" ajax="false"
                                             onclick="confirmDelete.hide();" 
                                             type="button" />  
                        </p:confirmDialog>
                    <!--</p:panel>-->
                    
                </p:tab>
                
                <p:tab title="Crear" disabled="false" >
                    <ui:include src="crearRol.xhtml" />
                </p:tab>
                
                <p:tab title="Modificar" disabled="false" >
                    <label for="title">ROL : </label>  
                    <p:inputText value="#{rolBean.selectedRol.name}"  
                                 disabled="true"/>  
                    <br />
                    <label for="title">Lista de Privilegios</label>  
                    
                    <p:pickList id="ListPrivilegesEdit" value="#{rolBean.privileges}" 
                                var="privilege" effect="bounce"
                                itemValue="#{privilege}" itemLabel="#{privilege}" 
                                showSourceControls="false" showTargetControls="false" 
                                showSourceFilter="true" showTargetFilter="true" 
                                showCheckbox="true" filterMatchMode="contains" >  

                        <f:facet name="sourceCaption">Disponibles</f:facet>  
                        <f:facet name="targetCaption">Agregados</f:facet>  

                        <p:ajax event="transfer" listener="#{rolBean.onTransfer}" update="msgCR" />  


                        <p:column style="width:90%;">  
                            #{privilege}  
                        </p:column>  

                    </p:pickList> 
                    

                </p:tab>
                
                
            </p:tabView>
            
<!--            <h:panelGrid style="margin: 0 auto" columns="2" >
                <p:outputLabel value="Borrar Usuario Seleccionado: "/>
                <p:commandButton value="Drop" style="color: #2480BC;"  action="{tableRol.drop()}" oncomplete="carDialog2.show()" update=":droprol:mess">
                    <p:confirm header="Confirmation" message="Esta Seguro de Realizar Esta accion?" icon="ui-icon-alert" /> 
                </p:commandButton>   
                <p:confirmDialog global="true" showEffect="fade" hideEffect="explode">  
                    <p:commandButton value="Yes" type="button" styleClass="ui-confirmdialog-yes" icon="ui-icon-check"/>  
                    <p:commandButton value="No" type="button" styleClass="ui-confirmdialog-no" icon="ui-icon-close"/>       
                </p:confirmDialog> 
            </h:panelGrid> -->
        </h:form>
                
<!--        <h:form id="droprol">
            <p:dialog header="Atencion!!" widgetVar="carDialog2" 
                      position="center" modal="false" width="200" 
                      height="100"  visible="false" showEffect="explode" 
                      hideEffect="explode" resizable="false" closable="false" >  
                <p:outputPanel id="carDetail" style="text-align:center;" layout="block">   
                    <h:panelGrid>  
                        <h:outputText value = "{tableRol.message}" id="mess" style="text-align: center"/>
                        <p:commandButton value="Aceptar"  update=":formlistUser:dataTableUsers" oncomplete="carDialog2.hide()"/>
                    </h:panelGrid>  
                </p:outputPanel>  
            </p:dialog>
        </h:form>-->
    </h:body>
</html>
